home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
cli
/
mx2src.arc
/
ATOMIC.DEF
< prev
next >
Wrap
Text File
|
1989-01-05
|
15KB
|
305 lines
DEFINITION MODULE ATOMIC;
(* Copyright 1987,1988 fred brooks LogicTek *)
(* *)
(* *)
(* First Release 12/8/87-FGB *)
(* Added variable parm to StartProcess to pass info to process *)
(* in currentprocess.gemsave[15] 1/1/88-FGB *)
(* *)
(* Remove monitor priority. Each routine the switches processes *)
(* must be protected from all interrupts by the IntEnd and *)
(* IntBegin calls. If this is not done correctly the system *)
(* system will bomb. 4/4/88-FGB *)
(* *)
FROM SYSTEM IMPORT ADDRESS,BYTE;
FROM NEWSYS IMPORT PROCESS;
FROM Strings IMPORT String;
CONST MAGIC = 22261; (* somebodys b-day *)
buflength = 1024;
OTOS = LONGCARD(602CH); (* Old rom TOS *)
MTOS = LONGCARD(87CEH); (* New rom MEGA TOS *)
OLDDATE = 11201985H;
NEWDATE = 04221987H;
VERSION = " MX2 V2.3.0"; (* mx2 version number *)
TYPE
Gvectype = POINTER TO ADDRESS;
buffer = ARRAY [0..buflength] OF BYTE;
PIPE = RECORD
pipename: String;
buf : buffer;
bufsize : CARDINAL;
bufhead : CARDINAL;
buftail : CARDINAL;
cnt : CARDINAL;
END;
pipeptr = POINTER TO PIPE;
(* these devices are defined for use with the MX2 port command
dev0 thru dev7 are user defineable device drivers. By loading
the addresses of the correct procedures into the DeviceTable for
in, out and status custom devices may be defined.
DeviceTable[dev0].bconstat:=Mybconstat;
DeviceTable[dev0].bcostat:=Mybcostat;
DeviceTable[dev0].bconin:=Mybconin;
DeviceTable[dev0].bconout:=Mybconout;
Will setup dev0 for use with the port command.
sys port 4 -0 -0
will cause the process with the PID of 4 to use dev0
*)
devicetype = (printer,aux,con,midi,null,dev0,dev1,dev2,dev3,
dev4,dev5,dev6,dev7);
devstattype = PROCEDURE(): BOOLEAN;
devintype = PROCEDURE(): LONGCARD;
devouttype = PROCEDURE(CHAR);
devblocktype = RECORD
bconstat : devstattype;
bcostat : devstattype;
bconin : devintype;
bconout : devouttype;
END;
devtabletype = ARRAY [ORD(dev0)..ORD(dev7)] OF devblocktype;
TYPE SIGNAL = POINTER TO ProcessDescriptor;
GEMTYPE = ARRAY [0..0FFH] OF ADDRESS;
pipetype = ARRAY [0..31] OF pipeptr;
(* pipe names starting with mx2 or MX2 are reserved by the
system *)
(* This is the control record for all system process. Variable
"currentprocess" points to the currently running process. The ready
queue is implemented as a linked list round robin. *)
(* The gemsave array contains important system vectors that are switched
with every process. This allows programs to intercept trap vectors
such as the GEMDOS TRAP 1 and still to allow the other programs
to run correctly. current vectors saved are
gemsave[0] gem workspace pointer
gemsave[1] LINEA VECTOR 28H
gemsave[2] GEMDOS TRAP 1 84H
gemsave[3] GSX,GEM TRAP 2 88H
gemsave[4] BIOS TRAP 13 B4H
gemsave[5] XBIOS TRAP 14 B8H
gemsave[6] linef VECTOR 2CH
gemsave[7] level2 VECTOR 68H
gemsave[8] level4 VECTOR 70H
gemsave[9] _shell_p 4F6H
gemsave[11] wait value (* V2.2.0 *)
gemsave[12] wait mask (* V2.2.0 *)
gemsave[13] sleep timer variable
gemsave[14] timer flag variable
gemsave[15] init parameter for process
misc[0] priority work variable
*)
ProcessDescriptor =
RECORD
name : String; (* process name *)
pid : INTEGER; (* process id *)
cor : PROCESS; (* process coroutine *)
pc : ADDRESS; (* process PC *)
sr : CARDINAL; (* process SR *)
ssp : ADDRESS; (* process super SR *)
biosval : ADDRESS; (* bios call save ptr *)
retval : ADDRESS;
biosave : ARRAY [0..225] OF CARDINAL;
gemsave : ARRAY [0..15] OF ADDRESS;
termvec : ADDRESS;
wsp : ADDRESS; (* process work space *)
wspsize : LONGCARD; (* size of work space *)
next : SIGNAL; (* ptr to next process *)
ppid : INTEGER; (* parent id *)
tmpcor : PROCESS; (* cor save variable *)
ready : BOOLEAN; (* process run flag *)
active : BOOLEAN; (* process alive flag *)
intflag : BOOLEAN; (* process switched *)
date : CARDINAL; (* date started *)
time : CARDINAL; (* time started *)
tick : LONGCARD; (* total 200hz clocks *)
slice : LONGCARD; (* restart time 200hz *)
pri : INTEGER; (* set length of run *)
flags : ARRAY [0..2] OF LONGCARD; (* var *)
(* flags[0] is default drive of process that called the kernel
flags[1] is address of process to be added to ready list of kernel
flags[2] is size of process stack or workspace
*)
ipname : String; (* program name *)
iptail : String; (* program command *)
ipenvstr : String; (* program env string *)
return : INTEGER; (* function return *)
errno : INTEGER; (* error number *)
bpsave : GEMTYPE; (* save for gemdos *)
Iport : devicetype;
Oport : devicetype;
waitloc : POINTER TO LONGCARD; (* V2.2.0 *)
misc : ARRAY [0..8] OF INTEGER;
END;
(* Vector 144H points to variable that contains this record *)
(* look at SYS.MOD for an example of use of these variables *)
sysrequesttype =
RECORD
req : BOOLEAN;
pid : INTEGER;
magic : LONGCARD;
END;
spinttype =
RECORD
proc : PROC;
pid : INTEGER;
data : ADDRESS;
END;
StartProcesstype = PROCEDURE(VAR PROC,VAR LONGCARD,
VAR INTEGER,VAR String,
VAR ADDRESS);
SwapProcesstype